import { DependencyList, RefObject, useEffect } from "react";
/**XXX变化后自动滚动到底部
 * @param Ref 滚动的ref
 * @param deps useEffect第二个参数，什么变化时进行滚动
 */
export const useScrollToBottom = (scrollRef: RefObject<HTMLDivElement>, deps: DependencyList = []) => {
    useEffect(() => {
        setTimeout(() => {
            scrollRef.current?.scrollTo({
                behavior: "smooth",
                top: scrollRef.current.scrollHeight,
            });
        }, 100);
    }, deps);
}